<template>
  <div>
    <el-card class="box-card" :body-style="{padding:'5px'}">
      <div class="clearfix" style="padding:5px;">
        <span style="line-height: 36px;">详情</span>
      </div>

      <el-form ref="form" :model="form" label-width="120px">

        <el-row>
          <el-col :span="12">
            <el-form-item label="企业编号:" prop="profileId">
              <el-input v-model="form.profileId" placeholder="输入企业编号" :disabled="true" style='width: 100%'></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="企业名称:" prop="profileName">
              <el-input v-model="form.profileName" placeholder="输入企业名称" :disabled="true" style='width: 100%'></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="银行账户名称:" prop="ubOrganBankOwner">
              <el-input v-model="form.ubOrganBankOwner" placeholder="输入经办人姓名" :disabled="true" style='width: 100%'></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="开户银行:" prop="ubBankName">
              <el-input v-model="form.ubBankName" placeholder="输入经办人身份证" :disabled="true" style='width: 100%'></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="银行账号:" prop="ubOrganBankNo">
              <el-input v-model="form.ubOrganBankNo" placeholder="输入经办人手机号" :disabled="true" style='width: 100%'></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="支行名称:" prop="ubBankBranchName">
              <el-input v-model="form.ubBankBranchName" placeholder="输入经办人手机号" :disabled="true" style='width: 100%'></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item>
          <el-button type="info" @click="saveHandler" :disabled="disableForm">不同意</el-button>
          <el-button type="danger" @click="resetHandler" :disabled="disableForm">同意</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>


<script type="text/babel">
  import assignDeep from 'assign-deep'
  import {mapActions} from 'vuex'

  import bankManagementStore from './bll/bankManagementStore'
  import store from '../../store'

  (!store.state.bankManagementStore) && store.registerModule('bankManagementStore', bankManagementStore)

  export default {
    data() {
      return {
        disableForm: true,
        pageModel: 'ADD',
        form: {
          profileId: '',
          profileName: '',
          ubOrganBankOwner: '',
          ubBankName: '',
          ubOrganBankNo: '',
          ubBankBranchName: '',
          auditStatus: '',
          organBankId: ''
        }
      }
    },

    props: {
      param: {
        type: Object
      },
      mode: {
        type: String
      }
    },

    watch: {
      param(record) {
        if (record) {
          this.form.profileId = record.profileId;
          this.form.profileName = record.profileName;
          this.form.ubOrganBankOwner = record.ubOrganBankOwner;
          this.form.ubBankName = record.ubBankName;
          this.form.ubOrganBankNo = record.ubOrganBankNo
          this.form.ubBankBranchName = record.ubBankBranchName;
          this.form.auditStatus = record.auditStatus;
          this.form.organBankId = record.organBankId;
        } else {
          assignDeep(this.form, {
            profileId: '',
            profileName: '',
            ubOrganBankOwner: '',
            ubBankName: '',
            ubOrganBankNo: '',
            ubBankBranchName: '',
            auditStatus: '',
            organBankId: ''
          });
        }
      },
      mode(val) {
        this.pageModel = val;
      }
    },

    mounted() {
      this.initPage();
    },

    methods: {
      ...mapActions(['editBank']),
      saveHandler() {
        var newform = this.form
        newform.auditStatus = 0
        var data = this.editBank({formData: newform})
        console.log(this.form)
        console.log(data)
        if (data) {
          this.$message({
            message: '操作成功',
            type: 'success'
          });
          //this.$parent.querySuggestions({pageIndex: this.$parent.pageIndex, pageSize: this.$parent.pageSize});
        }
        this.disable()
      },

      resetHandler() {
        var newform = this.form
        newform.auditStatus = 1
        var data = this.editBank({formData: newform})
        console.log(this.form)
        console.log(data)
        if (data) {
          this.$message({
            message: '操作成功',
            type: 'success'
          });
          //this.$parent.querySuggestions({pageIndex: this.$parent.pageIndex, pageSize: this.$parent.pageSize});
        }
        this.disable()
      },

      initPage() {

      },

      // interface for invoking

      disable() {
        this.disableForm = true;
      },
      enable() {
        this.disableForm = false;
      },
      clear() {
        this.$refs.form.resetFields();
      }

    }
  }
</script>

